#include <iostream>

using namespace std;

typedef long long LL;
const int N = 3e5 + 10;
LL a[N], b[N];
int n; 
bool check(LL mid)
{
    LL l = a[1] - mid * b[1], r = a[1] + mid * b[1];
    for(int i = 2; i <= n; i++)
    {
        LL nl = a[i] - mid * b[i];
        LL nr = a[i] + mid * b[i];
        l = max(l, nl);
        r = min(r, nr);
        if(l > r) return false;
    }
    return true;
}

void solve()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];
    LL l = 0, r = 1e9;
    while(l < r)
    {
        LL mid = (l + r) >> 1;
        if(check(mid)) r = mid;
        else l = mid + 1;
    }
    cout << l << endl;
}

int main()
{
    int T; cin >> T;
    while(T--)
    {
        solve();
    }
    return 0;
}